<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加公告</title>
    <th:block th:include="common.html :: source"></th:block>
    <link href="/static/layui/css/layui.css" rel="stylesheet">


</head>
<style>
    #b1{
        background-color: #008080;
        width: 90px;
        height: 40px;
        color: #ffffff;
        border: 0;
    }
    #b1:hover{
        cursor: pointer;
        border: 0;
        background-color: #008B8B;
    }
    body{
        margin: 20px;
    }
    .panel-head {
        background-color: #fcfcfc;
        padding: 10px 15px;
        border-radius: 4px 4px 0 0;
        border-bottom: solid 4px #c2c2c2;
    }
</style>
<body>
<div style="" class="panel-head layui-anim layui-anim-down"><strong> 发布公告</strong></div>
<form class="layui-form" action="">

<!--    <p>标题: <input type="text" class="layui-input" onblur="" name="title" id="title" lay-verify="required"/>-->
<!--    </p>-->
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" id="title" required autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>
<!--    <p style="width: 1250px;height: 400px">内容: <textarea id="text_regulation"-->
<!--                                                         style="width: 1250px;height: 400px"></textarea></p>-->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">文本域</label>
        <div class="layui-input-block" style="width: 85%">
            <textarea rows="14" cols="80" class="span12 ckeditor" id="editor" name="content" title="" type="text/plain"></textarea>
            <span id="err_goods_content" style="color:#F00; display:none;"></span>
        </div>
    </div>

    <p style="margin-top: 30px;padding-left: 100px">
        <button lay-submit="" id="b1">确认发布</button>
    </p>

</form>


<script src="/static/layui/layui.js" charset="UTF-8"></script>

<script type="text/javascript" src="/static/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/Ueditor/ueditor.all.js"></script>

<script src="/static/Ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charset="utf-8" ></script>
<script>

    var ue = UE.getEditor('editor');

    layui.use(['layedit', 'form', 'layer'], function () {
        var layedit = layui.layedit;
        var form = layui.form;
        var layer = layui.layer;
        form.on('submit()', function () {
            $.post({
                url: "/manage/saveBulletin",
                data: {
                    "id": $('#id').val(),
                    "title": $('#title').val(),
                    "content": $('#content').val(),
                },
                success: function (data) {
                    if (data.code === 0) {
                        layer.msg('发布成功', {icon: 6, offset: "auto", time: 2000});//提示框
                        //更新查询标题在公告中显示
                        var ul = window.parent.document.getElementsByClassName("gonggao");
                        var url = "/manage/toBulletin";
                        $(ul).append('<dd id="' + $('#title').val() + '"><a href="javascript:;" tab-layid="'+$('#id').val()+'" class="site-active" tab-name="'+$('#title').val()+'" tab-url=  "' + url + '?title=' + $('#title').val() + '"><div style="padding-left: 35px">' + $('#title').val() + '</div></a></dd>')
                    } else {
                        layer.msg('发布失败', {icon: 5, offset: "auto", time: 2000});//提示框
                    }
                    setTimeout(function () {
                        var index = layer.getFrameIndex(window.name);
                        layer.close(index);//关闭弹出层
                        location.reload();
                    }, 2100);
                }

            });
            return false;
        })
    });




</script>



</body>
</html>


